package com.wyz.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wyz.entity.ClassEntity;
import com.wyz.entity.CourseEntity;
import com.wyz.mapper.CourseMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wk
 * @desc
 * @date 2024/12/25 10:40
 */
@Service
public class CourseService {
    @Resource
    private CourseMapper courseMapper;
    public IPage<CourseEntity> getCourseListByPage(int currentPage) {
        IPage<CourseEntity> page = new Page<>(currentPage, 5); // 每页显示5条数据
        IPage<CourseEntity> bookListPage = courseMapper.selectPage(page,null);
        return bookListPage;
    }
    public boolean addCourse(CourseEntity courseEntity) {
        return courseMapper.insert(courseEntity)>0;
    }

    public CourseEntity queryCourseById(Integer courseId) {
        return courseMapper.selectById(courseId);
    }

    public boolean updateCourse(CourseEntity courseEntity) {
        return courseMapper.updateById(courseEntity)>0;
    }

    public boolean deleteCourse(Integer courseId) {
        return courseMapper.deleteById(courseId)>0;
    }
}
